import { defineStore } from 'pinia';

export const STORE_KEY_OPTION_STORE = 'option-store';

export interface OptionStoreState {
  recordField: Record<string, string>;
}

export const useOptionStore = defineStore(STORE_KEY_OPTION_STORE, {
  state: (): OptionStoreState => ({
    recordField: {},
  }),
  actions: {
    setHashValue(key: string, value: string) {
      this.recordField[key] = value;
    },
    setHashValues(...datas: Array<{ key: string; value: string }>) {
      datas.forEach(({ key, value }) => {
        this.setHashValue(key, value);
      });
    },
  },
});
